package cn.tips.dmp.system.assist.message.controller;

import cn.tips.dmp.supports.result.ApiResultDTO;
import cn.tips.dmp.supports.result.ApiResultGenerator;
import cn.tips.dmp.system.assist.message.dto.SystemMessageReceiverDto;
import cn.tips.dmp.system.assist.message.mapper.SystemMessageTextMapper;
import cn.tips.dmp.system.assist.message.service.SystemMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 日志Controller
 *
 */
@RestController
@RequestMapping("/api/common/systemMessage")
@Slf4j
public class SystemMessageCommonController {

    @Autowired
    private SystemMessageService systemMessageService;
    @Autowired
    private SystemMessageTextMapper systemMessageTextMapper;


    @PostMapping("/setMessageRead")
    public ApiResultDTO setMessageRead(@RequestBody SystemMessageReceiverDto dto) {
        ApiResultDTO apiResultDto;
        try {
            systemMessageService.setReadState(dto.getId());

            apiResultDto = ApiResultGenerator.create("0", "操作成功!", "");
        } catch (Exception e) {
            log.error("分页数据获取失败:", e);
            e.printStackTrace();
            apiResultDto = ApiResultGenerator.create("-1", "操作失败!");
        }
        return apiResultDto;
    }
}
